$(document).ready(function () {

    /*search 切换*/
    $("[ss-search]").click(function (event) {
        $(this).addClass('current').siblings().removeClass("current");
        var sh = $(this).attr("ss-search");
        $("[ss-search-show=" + sh + "]").show().siblings().hide();
    });

    $.ajax({
        url: ctx+'/goodType/getTypeTree.do',
        dataType: 'json',
        type: 'post',
        success: function (nodes) {
            for (var i = 0; i < nodes.length; i++) {
                $('<div class="kj-info1" mg="' + nodes[i].code + '">'+
                    '<dl class="kj-dl1"><dt><a href="#">' + nodes[i].name + '</a></dt></dl>'+
                  '</div>').appendTo($('.kj-show2')).append('<div class="kj-if-show" mg2="'+nodes[i].code+'">');
                for(var j=0;j<nodes[i].children.length;j++){
                    $("[mg2="+nodes[i].code+"]").append("<dl><dt>"+nodes[i].children[j].name+"</dt><dd></dd><div style='clear:both;'></div></dl>");
                    for(var k=0;k<nodes[i].children[j].children.length;k++){
                        $('[mg2='+nodes[i].code+'] dd:eq('+j+')').append($('<a href="'+ctx+'/good/searchPage.do?goodTypeId='+nodes[i].children[j].children[k].id+'">'+nodes[i].children[j].children[k].name+'</a>'));
                    }
                }
            }

            /*商品分类快捷*/
            $("[mg]").hover(function () {
                $(this).addClass("hover-show-bg");
                var a1 = $(this).attr("mg");
                $("[mg2=" + a1 + "]").show();
            }, function () {
                $(this).removeClass("hover-show-bg");
                var a1 = $(this).attr("mg");
                $("[mg2=" + a1 + "]").hide();
            });
        }
    });
});











